package quick_sort;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: sfy
 * @Date: 2024/1/25 10:08
 * @Description: 第k个数
 */
public class Main2 {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s = bufferedReader.readLine();
        String[] split = s.split(" ");
        int n = Integer.parseInt(split[0]);
        int k = Integer.parseInt(split[1]);
        String s1 = bufferedReader.readLine();
        String[] split1 = s1.split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Integer.parseInt(split1[i]);
        }
        quickSort(arr,0, arr.length-1);
        System.out.println(arr[k-1]);
    }

    private static void quickSort(int[] arr,int l,int r){
        if(l>=r) return;
        int i=l-1,j=r+1,t = arr[(l+r)>>1];
        while(i<j){
            while(arr[++i]<t);
            while(arr[--j]>t);
            if(i<j){
                int temp = arr[i];
                arr[i]  = arr[j];
                arr[j] = temp;
            }
        }
        quickSort(arr,l,j);
        quickSort(arr,j+1,r);
    }
}
